﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;

namespace HYSoft.Web.Controls
{
    public partial class top : System.Web.UI.UserControl
    {
        public string  username;
        public string usertype;
        protected void Page_Load(object sender, EventArgs e)
        {
            username = Session["Username"].ToString();
            usertype = Session["Usertype"].ToString();
        }
        protected string usernames()
        {
            return username;
        }
        protected string getlist()
        {
            string status = "";
            string CurrentPath = HttpContext.Current.Server.MapPath("./");//当前路径。
            string FilePath=CurrentPath+"title_node.xml";
            XmlDocument xml = new XmlDocument();
            //读取xml文件
            xml.Load(FilePath);  //你的xml地址
            //////////*******下面开始循环读取xml文件信息********/
            ///////////////
            string nodetext="";
            string link = "#" ;
            foreach (XmlNode node in xml.ChildNodes)
            {
                if (node.Name == "Title")
                {
                    foreach (XmlNode node1 in node)
                    {
                        if (node1.Name == "title_node")
                        {
                            //整个内容包括link的内容，如：首页main.xml
                            nodetext = node1.InnerText;
                            foreach (XmlNode node2 in node1)
                            {
                                if (node2.Name == "title_link")
                                    //获取连接，如：main.xml
                                    link = node2.InnerText;
                            }
                            //得到标题名称，如nodetext为首页
                            nodetext = nodetext.Substring(0,nodetext.Length-link.Length);
                        }
                        //向页面增加一个标题
                     status+="<li class='listli'><a href="+link+">"+ nodetext +"</a></li>";
                    }
                   
                }
            }
            return status;
        }
 
    }
}